package com.share;

import android.app.Activity;

import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.controller.RequestType;
import com.umeng.socialize.controller.UMServiceFactory;
import com.umeng.socialize.controller.UMSocialService;
import com.umeng.socialize.sso.QZoneSsoHandler;
import com.umeng.socialize.sso.SinaSsoHandler;
import com.umeng.socialize.sso.TencentWBSsoHandler;

@SuppressWarnings("javadoc")
public class UmengUtil {

	public static UMSocialService getUMSocialService(Activity act) {
		UMSocialService ums = UMServiceFactory.getUMSocialService("com.umeng.share", RequestType.SOCIAL);

		// (1)授权成功后的回调函数-登录
		// 设置QQ空间Handler
		ums.getConfig().setQZoneSsoHandler(new QZoneSsoHandler(act));
		// 设置新浪SSO handler
		ums.getConfig().setSinaSsoHandler(new SinaSsoHandler());
		// 设置腾讯微博SSO handler
		ums.getConfig().setTencentWBSsoHandler(new TencentWBSsoHandler());

		// (2)删除某些支持分享的平台-分享
		// ums.getConfig().removePlatform(SHARE_MEDIA.SMS);
		ums.getConfig().removePlatform(SHARE_MEDIA.EMAIL);
		ums.getConfig().removePlatform(SHARE_MEDIA.DOUBAN);

		// (3)添加支持分享的平台-分享
		// 添加微信平台，参数1为当前Activity, 参数2为用户申请的AppID, 参数3为点击分享内容跳转到的目标url
		ums.getConfig().supportWXPlatform(act, Config.WEIXIN_APP_ID, Config.SHARE_CONTENT_URI);
		// 支持微信朋友圈
		ums.getConfig().supportWXCirclePlatform(act, Config.WEIXIN_APP_ID, Config.SHARE_CONTENT_URI);
		// 支持QQ
		ums.getConfig().supportQQPlatform(act, Config.SHARE_CONTENT_URI);

		// (4)设置分享平台选择面板的平台显示顺序
		ums.getConfig().setPlatformOrder(SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA, SHARE_MEDIA.TENCENT, SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.RENREN);
		
		return ums;
	}
}
